{% extends "base_worklist.html" %}
{% load work_custom_filters %}  
{%block title%}
Cihaz İstesi
{%endblock%}
{%block content%}

<div id="filtrelemeler" style="margin-left: 50px;">
	<table style="font-size: 9px; margin-bottom: 3px;">
	<tr>
		<td><b>Bakım/Kalib. :</b></td><td{%ifequal bakimlar "E" %} style="color: black; background-color: #FFDD00;" {%endifequal%}>{%ifequal bakimlar "E"%}<a href="/worklist/sabitler/2/?H={{H|default_if_none:"L"}}&Durum={{Durum|default_if_none:"H"}}">Bakım/Kalibrasyonları Kapat</a>{% else %}<a href="/worklist/sabitler/2/?bakimlar=E&H={{H|default_if_none:"L"}}&Durum={{Durum|default_if_none:"H"}}">Bakım/Kalibrasyonları Göster</a>{%endifequal%}</td>
		<td><b>Boyut :</b></td><td{%ifequal H "L" %} style="color: black; background-color: #FFDD00;" {%endifequal%}><a href="/worklist/sabitler/2/?bakimlar={{bakimlar|default_if_none:"H"}}&H=L&Durum={{Durum|default_if_none:"H"}}">Uzun</a></td><td{%ifequal H "S" %} style="color: black; background-color: #FFDD00;" {%endifequal%}><a href="/worklist/sabitler/2/?bakimlar={{bakimlar|default_if_none:"H"}}&H=S&Durum={{Durum|default_if_none:"H"}}">Kısa</a></td>
		<td><b>Durum :</b></td><td{%ifequal Durum|default_if_none:"H" "H" %} style="color:black; background-color:#FFDD00;" {%endifequal%}><a href="/worklist/sabitler/2/?bakimlar={{bakimlar|default_if_none:"A"}}&H={{H|default_if_none:"L"}}&Durum=H">Hepsi</a></td><td {%ifequal Durum "A"%}style="color: black; background-color: #FFDD00;"{%endifequal%}><a href="/worklist/sabitler/2/?bakimlar={{bakimlar|default_if_none:"H"}}&H={{H|default_if_none:"L"}}&Durum=A">Aktifler</a></td><td {%ifequal Durum "P"%}style="color: black; background-color: #FFDD00;"{%endifequal%}><a href="/worklist/sabitler/2/?bakimlar={{bakimlar|default_if_none:"H"}}&H={{H|default_if_none:"L"}}&Durum=P">Pasifler</a></td>
	</tr>
	<tr>
		<td colspan="9"><a href= "/worklist{{s.adres}}ekle/">Yeni Kayıt Ekle</a></td>
	</tr>
	</table>
</div>
<div style="letter-spacing:-1px; margin-left: auto; margin-right: auto; width: 80%;">
<div id="dt_example">
<div id="container">
<div id="demo">
<table cellpadding="0" cellspacing="0" border="0" class="display" id="example">

    <thead> 
    	<tr>
    		<td></td>
    		{%ifequal bakimlar "E"%}
    		<td></td> <!-- kalibz -->
    		<td></td>
 
 			<td></td>
 
    		<td></td>

    		<td></td> <!-- bakimz -->
    		<td></td>
 
 			<td></td>
 
    		<td></td>
    		{%endifequal%}
    		<td></td>
    		<td></td>
    		<td></td>
    		<td></td>
    		<td></td>
    		<td></td>
    		<td></td>
    		
    	</tr>
    <tr>
    		<th>Sno</th>
    		{%ifequal bakimlar "E"%}
	   		<th>Kal.<br>{{yil|prevint|prevint}}</th><!-- kalibz -->
    		<th>Kal.<br>{{yil|prevint}}</th>
    		
    		<th>Kal.<br>{{yil}}</th>
    		
    		<th>Kal.<br>{{yil|nextint}}</th>

	   		<th>Bak.<br>{{yil|prevint|prevint}}</th><!-- bakimz -->
    		<th>Bak.<br>{{yil|prevint}}</th>
    		
    		<th>Bak.<br>{{yil}}</th>
    		
    		<th>Bak.<br>{{yil|nextint}}</th>
			{%endifequal%}
     		<th>Açıklama</th>
    		<th>Lokasyon</th>
    		<th>Markası</th>
    		<th>Modeli</th>
    		<th>Seri no</th>   
    		<th>Demirbaş No</th>
    		<th>Aidiyeti</th>
    	</tr>
    </thead>
    <tbody>
    {% for ch in cihaz_list %}
     <tr {% ifnotequal ch.durum.id 1 %}class="gradeX"{%endifnotequal%}>  
			<td>	<a href="/worklist{{s.adres}}{{ ch.id }}/degistir/">{{ ch.sno }}</a></td>
			{%ifequal bakimlar "E"%}
			<td>{{yil|prevint|prevint|getkalibay:ch.id}}</td><!-- kalibz -->
    		<td>{{yil|prevint|getkalibay:ch.id}}</td>
    		<td>{{yil|getkalibay:ch.id}}</td>
    		<td>{{yil|nextint|getkalibay:ch.id}}</td>
    		
    		<td>{{yil|prevint|prevint|getbakay:ch.id}}</td><!-- bakimz -->
    		<td>{{yil|prevint|getbakay:ch.id}}</td>
    		<td>{{yil|getbakay:ch.id}}</td>
    		<td>{{yil|nextint|getbakay:ch.id}}</td>
    		{%endifequal%}
    		<td>{{ ch.aciklama|lower|capfirst|truncatewords:3 }}</td>
   			<td>{{ ch.lokasyon.aciklama|lower|capfirst|truncatewords:3 }}</td>
   			<td>{{ ch.markasi.aciklama|dotsifempty|lower|capfirst|truncatewords:2 }}</td>
   			<td>{{ch.modeli|dotsifempty|lower|capfirst|truncatewords:2}}</td>
   			<td>{{ ch.serino|dotsifempty }}</td>
   			<td>{{ ch.demirbasno}}</td>
   			<td>{{ ch.aidiyet.aciklama|lower|capfirst}}</td>     	

     </tr>
    {% endfor %}
	</tbody>

</table>
</div>
</div>
</div> 
</div>
{% endblock %}
{%block script%}
<link rel="stylesheet" title="currentStyle" type="text/css" href="/media/css/demo_page.css" /> 
<link rel="stylesheet" title="currentStyle" type="text/css" href="/media/css/demo_table.css" /> 
<link rel="stylesheet" title="currentStyle" type="text/css" href="/media/css/TableTools.css" /> 
<script type="text/javascript" language="javascript" src="/media/js/jquery.dataTables.js"></script>
<script type="text/javascript" charset="utf-8" src="/media/js/ZeroClipboard.js"></script>
<script type="text/javascript" charset="utf-8" src="/media/js/TableTools.js"></script>
 
<script type="text/javascript" charset="utf-8"> 
//filtre kutulari
    (function($) {
	/*
	 * Function: fnGetColumnData
	 * Purpose:  Return an array of table values from a particular column.
	 * Returns:  array string: 1d data array 
	 * Inputs:   object:oSettings - dataTable settings object. This is always the last argument past to the function
	 *           int:iColumn - the id of the column to extract the data from
	 *           bool:bUnique - optional - if set to false duplicated values are not filtered out
	 *           bool:bFiltered - optional - if set to false all the table data is used (not only the filtered)
	 *           bool:bIgnoreEmpty - optional - if set to false empty values are not filtered from the result array
	 * Author:   Benedikt Forchhammer <b.forchhammer /AT\ mind2.de>
	 */
	$.fn.dataTableExt.oApi.fnGetColumnData = function ( oSettings, iColumn, bUnique, bFiltered, bIgnoreEmpty ) {
		// check that we have a column id
		if ( typeof iColumn == "undefined" ) return new Array();
		
		// by default we only wany unique data
		if ( typeof bUnique == "undefined" ) bUnique = true;
		
		// by default we do want to only look at filtered data
		if ( typeof bFiltered == "undefined" ) bFiltered = true;
		
		// by default we do not wany to include empty values
		if ( typeof bIgnoreEmpty == "undefined" ) bIgnoreEmpty = true;
		
		// list of rows which we're going to loop through
		var aiRows;
		
		// use only filtered rows
		if (bFiltered == true) aiRows = oSettings.aiDisplay; 
		// use all rows
		else aiRows = oSettings.aiDisplayMaster; // all row numbers

		// set up data array	
		var asResultData = new Array();
	
		for (var i=0,c=aiRows.length; i<c; i++) {
			iRow = aiRows[i];
			
			var aData = this.fnGetData(iRow);
			var sValue = aData[iColumn];

			// ignore empty values?
			if (bIgnoreEmpty == true && sValue.length == 0) continue;

			// ignore unique values?
			else if (bUnique == true && jQuery.inArray(sValue, asResultData) > -1) continue;
			
			// else push the value onto the result data array
			else asResultData.push(sValue);

			
		}
		
		return asResultData;
		
	}}(jQuery));


	function fnCreateSelect( aData )
	{
		var r='<select><option value=""></option>', i, iLen=aData.length;
		for ( i=0 ; i<iLen ; i++ )
		{
			r += '<option value="'+aData[i]+'">'+aData[i]+'</option>';
		}
		return r+'</select>';
	}

	$(document).ready(function() {
		/*
		 * First step is to create title attributes for the rows in the table
		 * This isn't needed if the required 'title' attribute is already set in the HTML in the
		 * DOM 
		 */

		/*			 
		$('#example tbody tr').each( function() {
			var sTitle;
			var nTds = $('td', this);
			var sAck = $(nTds[4]).text();	
			sTitle =  sAck
			
			this.setAttribute( 'title', sTitle );
		} );
		*/
		
		/* Apply the tooltips */
		/*$('#example tbody tr[title]').tooltip( {
			"delay": 0,
			"track": true,
			"fade": 250
		} );	
		*/

			
			var oTable = $('#example').dataTable(
						   {
							   "aaSorting": [[ 0, "asc" ]],
							   //"sPaginationType": "full_numbers",
							   //"iDisplayLength": 100,
							 	"sScrollX": "100%",
								{%ifequal bakimlar "E"%}
								"sScrollXInner": "180%",
								{% else %}
								"sScrollXInner": "120%",
								{%endifequal%}
								{%ifequal H "L" %}
								"sScrollY": "640px",
								{% else %}	
								"sScrollY": "350px",
								{%endifequal%}
								"bScrollCollapse": true,
								"bPaginate": false,
								"sDom": 'T<"clear">lfrtip',
								"oTableTools": {
									"sSwfPath": "/media/swf/ZeroClipboard.swf",								
									"aButtons": [
										{
											"sExtends": "xls",
											"sButtonText": "Excel'e Aktar"
										}
									]
								},
						  		"oLanguage": {
								"sLengthMenu": "Sayfa başına _MENU_ kayıt gösteriliyor",
								"sZeroRecords": "Kriter Bulunamadı ",
								"sInfo": "Toplam _TOTAL_ kayıttan _START_ ile _END_ arası kayıtlar",
								"sInfoEmpty": "0 kayıt ",
								"sInfoFiltered": "(Toplam _MAX_ kayıttan filtrelenenler)"
								
							} 
					
				}
				);
	
			/* Add a select menu for each TH element in the table footer */
			 $("thead td").each( function ( i ) {
				
			    
				if (i>0)
				{

					this.innerHTML = fnCreateSelect( oTable.fnGetColumnData(i).sort() );
					$('select', this).change( function () {
						if (!($(this).val()==""))
						{
							oTable.fnFilter( '^'+$(this).val()+'$', i ,true);
						}
						else
						{
							oTable.fnFilter( $(this).val(), i );
						}
					} );

				}
			} ); 
					
		
	} );
</script> 
<script type="text/javascript" charset="utf-8"> 
function fnGetSelected()
{
	var oTableLocal = $('#example').dataTable( );
	
	var aReturn = new Array();
	var aTrs = oTableLocal.fnGetNodes();
	
	for ( var i=0 ; i<aTrs.length ; i++ )
	{
		if ( $(aTrs[i]).hasClass('row_selected') )
		{
			
			aReturn.push( aTrs[i] );
		}
	}
	
	return aReturn;
	
}

</script>
<script type="text/javascript" charset="utf-8">
function fnShowHide( iCol )
{
	/* Get the DataTables object again - this is not a recreation, just a get of the object */
	var oTable = $('#example').dataTable();
	
	var bVis = oTable.fnSettings().aoColumns[iCol].bVisible;
	oTable.fnSetColumnVis( iCol, bVis ? false : true );
}
</script>

{% endblock%}